package com.gxa.modules.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.vo.R;
import com.gxa.modules.mapper.CustomerReceivMapper;
import com.gxa.modules.pojo.CustomerReceiv;
import com.gxa.modules.service.CustomerReceivService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Service
public class CustomerReceivServiceImpl extends ServiceImpl<CustomerReceivMapper, CustomerReceiv> implements CustomerReceivService {

   @Autowired
    private CustomerReceivMapper customerReceivMapper;

    @Override
    public CustomerReceiv findById(Long id) {
        return baseMapper.selectById(id);
    }

    @Override
    public R selectcoditions(Date createTime, BigDecimal freight, Date reconciliationTime) {

        R r=new R();
        r.setCode(200);
        r.setMsg("筛选成功");
        List<CustomerReceiv> selectcoditions = customerReceivMapper.selectcoditions(createTime, freight, reconciliationTime);
        r.setData(selectcoditions);
        return r;
    }

    @Override
    public R findByreceivId(Integer receivId) {
        R r=new R();
        r.setCode(200);
        r.setMsg("成功");
        CustomerReceiv customerReceiv = customerReceivMapper.selectbyid(receivId);
        Integer billingStatus = customerReceiv.getBillingStatus();
        if(billingStatus==0){
            customerReceiv.setBillingStatus(1);
        }else {
            customerReceiv.setBillingStatus(0);
        }
       r.setData(customerReceiv);
        return r;
    }

    @Override
    public R addCustomerReceiv(CustomerReceiv customerReceiv) {
        R r=new R();
        r.setCode(200);
        r.setMsg("添加成功");
        int insert = customerReceivMapper.insert(customerReceiv);

        return r;
    }

 /*   @Autowired
    private CustomerReceivMapper customerReceivMapper;

    @Override
    public R find() {
        R r=new R();
        r.setCode(200);
        r.setMsg("查询成功");

        return null;
    }*/


}
